# Use postgres/postgres user/password credentials
version: '3.9'

services:
  db:
    image: postgres:16.2
    ports:
    - "5432:5432"
    restart: always
    # set shared memory limit when using docker-compose
    shm_size: 128mb
    environment:
      POSTGRES_PASSWORD: postgres

  init-db:
    build:
      context: ../
      dockerfile: ./DockerfileLiquibasePg
    command: liquibase update
    environment:
      LIQUIBASE_COMMAND_URL: "jdbc:postgresql://db:5432/postgres"
      LIQUIBASE_COMMAND_USERNAME: "postgres"
      LIQUIBASE_COMMAND_PASSWORD: "postgres"
      LIQUIBASE_COMMAND_CHANGELOG_FILE: "changelog/changelog.xml"
    depends_on:
      db:
        condition: service_started

  app:
    depends_on:
      init-db:
        condition: service_completed_successfully
    build:
      context: ../
      dockerfile: ./Dockerfile
    ports:
    - "8080:8080"


